# Importing Data
MEXICO <- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "V1:V239")

# Checking the Imported Data
View(MEXICO)
# Creating Time Series Data
MEXICO_ts <- ts(MEXICO, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
MEXICO_ts
sum(is.na(MEXICO_ts))
library(forecast)
MEXICO_ts <- tsclean(MEXICO_ts)
MEXICO_ts

# Identification: Plotting the Time Series Data
plot(MEXICO_ts)

# Estimating the appropriate model
MEXICO_ts_model <- auto.arima(MEXICO_ts)
MEXICO_ts_model

# Forecasting
options(max.print=1000000)
MEXICO_ts_forecast <- forecast (MEXICO_ts_model, level=c(95), h=255)
plot(MEXICO_ts_forecast)
MEXICO_ts_forecast             

# Exporting
write.table(MEXICO_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/MEXICO_TSA.csv", sep=",")
